//物流管理-物流列表
App.util.ns('Admin.Logistics.Logistics');
App.pages.add((function(){
    var NS = Admin.Logistics.Logistics;
    var page = new App.Page({
        name: 'logistics/logistics/index'
    });
    //页面初始化
    page.initStack.add('dataTable', function(){
        //面包屑导航
        this.setBreadcrumb([{
            icon: '<i class="fa fa-truck"></i>',
            content: '物流管理'
        }, {
            content: '物流列表'
        }]);
        this.dataTable = new App.DataTable({
            baseUrl: '/admin/logistics/logistics',
            dataUrl: 'lists',
            table: {
                id: 'id',
                main: 0,
                showId: true,
                columns: App.util.copy(NS.Conf.columns)
            },
            filter: [
                {type: 'keywords'},
                {type: 'timeRange'},
                {type: 'select', name: 'type', title: '类型', width: '90px', items: [
                    [0, '寄出'],
                    [1, '用户寄回'],
                    [2, '再次寄出']
                ]},
                {type: 'select', name: 'status', title: '订单状态', width: '90px', items: [
                    [-1, '待查询'],
                    [0, '查询异常'],
                    [1, '暂无记录'],
                    [2, '在途中'],
                    [3, '派送中'],
                    [4, '已签收'],
                    [5, '用户拒签'],
                    [6, '疑难件'],
                    [7, '无效单'],
                    [8, '超时单'],
                    [9, '签收失败'],
                    [10, '退回']
                ]},
            ],
            menu: [
                //{parent: 'add', permission: 'op:admin.orders.price.create'},
                {parent: 'view', permission: 'op:admin.orders.price.detail'},
                //{parent: 'edit', permission: 'op:admin.orders.price.update'},
                {parent: 'drop', permission: 'op:admin.orders.price.delete'},
                {parent: 'multiDrop', permission: 'op:admin.orders.price.multiDelete'},
                //{parent: 'oplog', permission: 'op:admin.orders.price.getOpLogs'}
            ],
            detail: {
                form: {
                    items: App.util.copy(NS.Conf.form),
                    onChange:function (form,data) {
                        var htmlStr = '';
                        var recordJson=data.record_json;
                        if(!recordJson){
                            htmlStr = '暂无物流信息';
                        }
                        if(recordJson){
                            recordJson = JSON.parse(data.record_json);
                            if(recordJson.constructor!== Array){
                                htmlStr = '暂无物流信息';
                            }
                            for (var i =0 ;i<recordJson.length;i++){
                                htmlStr += recordJson[i].time+':'+recordJson[i].context+'<br>';
                            }
                        }
                        form.formItems['record_json'].change(htmlStr);
                    }
                }
            }
        }, page);
        this.dataTable.fix(this.contentContainer);
        this.dataTable.loadData();
    });
    //页面刷新
    page.refreshStack.add('dataTable', function(){
        this.dataTable.loadData(true);
    });
    //页面销毁
    page.destroyStack.add('dataTable', function(){
        this.dataTable.destroy();
    });
    return page;
})());